package com.ruoyi.web.controller.app;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.ruoyi.app.domain.bo.AppImGroupApplyBo;
import com.ruoyi.app.domain.vo.AppImGroupApplyVo;
import com.ruoyi.app.service.IAppImGroupApplyService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 群组申请
 *
 * @author ruoyi
 * @date 2025-11-17
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/imGroupApply")
public class AppImGroupApplyController extends BaseController {

    private final IAppImGroupApplyService iAppImGroupApplyService;

    /**
     * 查询群组申请列表
     */
    @GetMapping("/list")
    public TableDataInfo<AppImGroupApplyVo> list(AppImGroupApplyBo bo, PageQuery pageQuery) {
        return iAppImGroupApplyService.queryPageList(bo, pageQuery);
    }


    /**
     * 新增群组申请
     */
    @Log(title = "群组申请", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody AppImGroupApplyBo bo) {
        return toAjax(iAppImGroupApplyService.insertByBo(bo) ? 1 : 0);
    }

    /**
     * 同意群组申请
     */
    @Log(title = "群组申请", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@RequestBody List<Long> ids) {
        return toAjax(iAppImGroupApplyService.updateByBo(ids) ? 1 : 0);
    }


}
